package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.CustomerNursingProjectMapper;
import com.zzyl.service.CustomerNursingProjectService;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description CustomerNursingProjectServiceImpl
 * @Author Wen Jie
 * @Date 2024-09-14
 */
@Service
public class CustomerNursingProjectServiceImpl implements CustomerNursingProjectService {
    @Autowired
    private CustomerNursingProjectMapper nursingProjectService;
    @Override
    public PageResponse<NursingProjectVo> getByPage(String name, Integer status, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        Page<NursingProject> nursingProjects = nursingProjectService.listByPage(name,status);
        PageResponse<NursingProjectVo> nursingProjectVoPageResponse = PageResponse.of(nursingProjects, NursingProjectVo.class);
        return nursingProjectVoPageResponse;
    }

    @Override
    public NursingProjectVo getById(Long id) {
        NursingProject nursingProject = nursingProjectService.getById(id);
        NursingProjectVo vo = BeanUtil.toBean(nursingProject, NursingProjectVo.class);
        return vo;
    }
}
